using System;
using Common.Unity.Extensions.PropertyMapper.Testing.Objects;
using Common.Unity.Testing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Testing.Core;

namespace Common.Unity.Extensions.PropertyMapper.Testing
{
	[TestClass]
	public class SimiliarPropertiesPolicyTests : UnityContainerTestBase
	{
		[TestMethod, Owner( TestOwners.MichaelD_Bang )]
		public void VerifySimilarPropertiesMappedProperlyFromEntityViewToEntity()
		{
			EntityView view = Container.Resolve<EntityView>( "SimilarProperties-IgnoreDisplayName" );
			Entity entity = Container.Resolve<Entity>( "SimilarProperties-IgnoreDisplayName", view );
			Assert.AreEqual( view.ID, entity.ID );
			Assert.AreEqual( view.Name, entity.Name );
			Assert.AreEqual( DateTime.Parse( view.Date ), entity.Date );
			Assert.AreEqual( "Heheh", entity.Comments );
		}

		[TestMethod, Owner( TestOwners.MichaelD_Bang )]
		public void VerifyIgnoredPropertyDidNotMapFromEntityViewToEntity()
		{
			EntityView view = Container.Resolve<EntityView>( "SimilarProperties-IgnoreDisplayName" );
			Entity entity = Container.Resolve<Entity>( "SimilarProperties-IgnoreDisplayName", view );
			Assert.AreEqual( "This should be ignored during mapping", entity.IgnoreDisplayName );
		}

		[TestMethod, Owner( TestOwners.MichaelD_Bang )]
		public void VerifySimilarPropertiesMappedProperlyFromEntityToEntityView()
		{
			Entity entity = Container.Resolve<Entity>( "SimilarProperties-IgnoreDisplayName" );
			EntityView view = Container.Resolve<EntityView>( "SimilarProperties-IgnoreDisplayName", entity );
			Assert.AreEqual( entity.ID, view.ID );
			Assert.AreEqual( entity.Name, view.Name );
			Assert.AreEqual( view.Date, "6/7/2009" );
			Assert.AreEqual( view.CommentsField, "These are my comments, suckface!" );
		}

		[TestMethod, Owner( TestOwners.MichaelD_Bang )]
		public void VerifyIgnoredPropertyDidNotMapFromEntityToEntityView()
		{
			Entity entity = Container.Resolve<Entity>( "SimilarProperties-IgnoreDisplayName" );
			EntityView view = Container.Resolve<EntityView>( "SimilarProperties-IgnoreDisplayName", entity );
			Assert.AreEqual( "Ignore me View", view.IgnoreDisplayName );
		}
	}
}